import { ElLoading } from "element-plus";

let loadingInstance: any = null;

export const translateRequest = (
    config: any
) => {
    if (!config.hideloading) {
        showLoading();
    }
};

export const showLoading = (text = "加载中") => {
    loadingInstance = ElLoading.service({
        lock: true,
        text: text,
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.1)",
    });
};

export const hideLoading = () => {
    loadingInstance?.close();
};
